summary refs log tree commit diff
path: root/app/posts/[slug]/page.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'app/posts/[slug]/page.tsx')
-rw-r--r--app/posts/[slug]/page.tsx28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/posts/[slug]/page.tsx b/app/posts/[slug]/page.tsx
new file mode 100644
index 0000000..2110a35
--- /dev/null
+++ b/app/posts/[slug]/page.tsx
@@ -0,0 +1,28 @@
+import { notFound } from 'next/navigation'
+import Markdown from 'markdown-to-jsx'
+
+import InfoBar from '~/components/InfoBar'
+import { getPostSlugs, loadSinglePage } from '~/utils/post'
+
+export async function generateStaticParams() {
+  const slugs = await getPostSlugs()
+  return slugs.map((slug: string) => ({ slug }))
+}
+
+export default async function Post({ params: { slug } }) {
+  const post = await loadSinglePage(slug)
+  if (!post) notFound()
+
+  return (
+    <>
+      <h1 className="pageTitle">
+        {post.title}
+      </h1>
+      <main className="mainColumn">
+        <InfoBar authorName={post.author} publishedDate={post.date} />
+        <Markdown>{post.body}</Markdown>
+      </main>
+    </>
+  )
+}
+